<%--
    Document   : login
    Created on : Sep 15, 2011, 8:24:31 AM
    Author     : Arturia
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login to Awesomebooks.com</title>
        <link href="css/style.css" rel="stylesheet" type="text/css"/>
        <link href="css/bannerstyle.css" rel="stylesheet" type="text/css"/>
        <link href="css/TableCSS.css" rel="stylesheet" type="text/css"/>

        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
        <%
                    String fail = (String) request.getSession().getAttribute("LOGINFAIL");
                    String failresult = "";
                    if(fail == null || fail == "false"){
                        failresult = "false";
                    }else{
                        failresult = "true";
                    }
  //                  String userExits = (String)request.getSession().getAttribute("USERNAMEEXITS");
//                    if(userExits == null || userExits == "false"){

        %>
        <script type="text/javascript">
            function checkNULL(){
                if(document.getElementById("username").value.toString().length == 0){
                    document.getElementById("username_error").style.visibility = "visible";
                    document.getElementById("password_error").style.visibility = "collapse";
                    document.getElementById("username").focus();
                    return false;
                } else if(document.getElementById("password").value.toString().length == 0){
                    document.getElementById("password_error").style.visibility = "visible";
                    document.getElementById("username_error").style.visibility = "collapse";
                    document.getElementById("password").focus();
                    return false;
                }else{
                    return true;
                }
            }
            function showError(){
                var fail = "<%=failresult%>";
                if(fail == "true"){
                    document.getElementById("error").style.visibility = "visible";
                }else{
                    document.getElementById("error").style.visibility = "hidden";
                }
            }
        </script>
    </head>
    <body onload="showError()">
        <div id="header-wrap">
            <div id="header">
                <div style="margin:0px; text-align: left; float: left;"> <span style="color: #FFFFFF; font-family:'Arial Black',Gadget,sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -2px;"><a href="index.jsp" style="color: #FFF; text-decoration: none;" title="Awesomebooks.com">AWESOMEBOOKS</a></span> <a style="color: #FFF; font-size: 18px; font-family: Georgia, 'Times New Roman', Times, serif; font-style:italic; font-weight:normal; text-decoration: none;" href="index.jsp" title="Find your own book">Find your own book</a> 	</div>
                <ul class="menu">

                    <!-- Begin Simple Item Without Drop -->
                    <li class="">
                        <a href="newrelease.jsp">New Release</a>
                    </li>
                    <li class="">
                        <a href="bestseller.jsp">Best Seller</a>
                    </li>
                    <li class="">
                        <a href="bookreview.jsp">Books Review</a>
                    </li>

                    <li class="drop">
                        <a href="#">Catalogs</a>
                        <span class="toggle">&nbsp;</span>
                        <ul>
                            <li><a href="Controller?Action=Search&searchText=literature&Category=true">Literature</a></li>
                            <li><a href="Controller?Action=Search&searchText=life style&Category=true">Life Style</a></li>
                            <li><a href="Controller?Action=Search&searchText=tutorial&Category=true">Tutorial</a></li>
                            <li><a href="Controller?Action=Search&searchText=discovery&Category=true">Discovery</a></li>
                            <li><a href="Controller?Action=Search&searchText=science&Category=true">Science</a></li>
                            <li><a href="Controller?Action=Search&searchText=kids&Category=true">Kids</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div id="underheader">
                <form action="Controller" method="POST">
                    <span id="searchbox" style="width:50%">
                        <input name="searchText" type="text" style="width:250px; border:1px solid #333333" />
                        <input name="Action" type="submit" value="Search" id="button" />
                    </span>
                    <span id="user" style="width:50%">
                        <a href="login.jsp">Login</a> |
                        <a href="register.jsp">Register</a>
                    </span>
                </form>
            </div>
        </div>
        <center>
            <br/>
            <div id="registerForm">
                <form action="Controller" method="POST" id="loginForm">

                    <fieldset>
                        <legend>Login Details</legend>
                        <div><label>Username</label><input name="username" id="username" type="text" style="border-color: #333333"/></div>
                        <div><label>Password</label><input name="password" id="password" type="password" style="border-color: #333333"/></div>
                        <div><label id="error" style="color: red; visibility: hidden; width: 350px;">Username or password is not valid</label></div>
                    </fieldset>
                    <button id ="button" type="submit" name="Action" value="Login" onclick="return checkNULL()">Login</button> <button id ="button" type="reset">Reset</button>
                    <div id="login_error_check" >
                        <label id="username_error" style="color: red; visibility: hidden; width: 300px">Username must be filled</label>
                        <label id="password_error" style="color: red; visibility: hidden; width: 300px">Password must be filled</label>
                    </div>
                </form>
            </div>
        </center>
        <br/>
    </body>
</html>
